/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cc.altius.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;

/**
 *
 * @author sagar
 */
@Entity
@Table(name = "user")
//@NamedQueries({
//    @NamedQuery(name = "User.findAll", query = "SELECT u FROM User u"),
//    @NamedQuery(name = "User.findByUserId", query = "SELECT u FROM User u WHERE u.userId = :userId"),
//    @NamedQuery(name = "User.findByUsername", query = "SELECT u FROM User u WHERE u.username = :username"),
//    @NamedQuery(name = "User.findByActive", query = "SELECT u FROM User u WHERE u.active = :active"),
//    @NamedQuery(name = "User.findByExpired", query = "SELECT u FROM User u WHERE u.expired = :expired"),
//    @NamedQuery(name = "User.findByFailedAttempts", query = "SELECT u FROM User u WHERE u.failedAttempts = :failedAttempts"),
//    @NamedQuery(name = "User.findByExpiresOn", query = "SELECT u FROM User u WHERE u.expiresOn = :expiresOn")})
public class User implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "USER_ID")
    private Integer userId;
    @Basic(optional = false)
    @Column(name = "USERNAME")
    private String username;
    @Basic(optional = false)
    @Lob
    @Column(name = "PASSWORD")
    private byte[] password;
    @Basic(optional = false)
    @Column(name = "ACTIVE")
    private boolean active;
    @Basic(optional = false)
    @Column(name = "EXPIRED")
    private boolean expired;
    @Basic(optional = false)
    @Column(name = "FAILED_ATTEMPTS")
    private short failedAttempts;
    @Basic(optional = false)
    @Column(name = "EXPIRES_ON")
    @Temporal(TemporalType.DATE)
    private Date expiresOn;

    public User() {
    }

    public User(Integer userId) {
        this.userId = userId;
    }

    public User(Integer userId, String username, byte[] password, boolean active, boolean expired, short failedAttempts, Date expiresOn) {
        this.userId = userId;
        this.username = username;
        this.password = password;
        this.active = active;
        this.expired = expired;
        this.failedAttempts = failedAttempts;
        this.expiresOn = expiresOn;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public byte[] getPassword() {
        return password;
    }

    public void setPassword(byte[] password) {
        this.password = password;
    }

    public boolean getActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public boolean getExpired() {
        return expired;
    }

    public void setExpired(boolean expired) {
        this.expired = expired;
    }

    public short getFailedAttempts() {
        return failedAttempts;
    }

    public void setFailedAttempts(short failedAttempts) {
        this.failedAttempts = failedAttempts;
    }

    public Date getExpiresOn() {
        return expiresOn;
    }

    public void setExpiresOn(Date expiresOn) {
        this.expiresOn = expiresOn;
    }

//    @Override
//    public int hashCode() {
//        int hash = 0;
//        hash += (userId != null ? userId.hashCode() : 0);
//        return hash;
//    }

//    @Override
//    public boolean equals(Object object) {
//        // TODO: Warning - this method won't work in the case the id fields are not set
//        if (!(object instanceof User)) {
//            return false;
//        }
//        User other = (User) object;
//        if ((this.userId == null && other.userId != null) || (this.userId != null && !this.userId.equals(other.userId))) {
//            return false;
//        }
//        return true;
//    }

  
}
